<template>
  <div>
    <h1>操作</h1>
    发布小说<van-field label="发布小说" v-model="conttent"/>
    <button @click="addd">点击发布小说</button>
    <br>
    <br>

    <button @click="sss">点击兑换礼品</button>
    <div v-show="iss">
      <div v-show="iss">
        <ul>
          <li v-for="i in giftlist" :key="i.id">{{i.name}}--{{i.integral}} -- <span style="background-color: aquamarine" @click="huan(i.id)">兑换</span> </li>
        </ul>
        <button @click="clo">取消</button>
      </div>
    </div>



  </div>
</template>

<script>
import myaxios from "@/http/axios";

export default {
  name: "is_caozuo",
  data() {
    return {
      data1: '',
      iss:false,
      userid:localStorage.getItem('userid'),
      conttent:'',
      giftlist:[]
    }
  },
  methods: {
    sss(){
      this.iss = true
    },
    clo(){
      this.iss = false
    },
    addd(){
      if (localStorage.getItem('is_admin')==1){
        myaxios('addnovel','post',{'uid':this.userid,'content':this.conttent}).then(res=>{
          alert(res.msg)
        })
      }else {
        alert('无权限')
      }
    },
    showgift(){
      if (localStorage.getItem('is_admin')==1) {
        myaxios('addgify', 'get').then(res => {
          this.giftlist = res.list
        })
      }else {
        alert('无权限')
      }
    },
    huan(id){
      myaxios('upgift?uid='+this.userid+'&gid='+id,'get').then(res=>{
        alert(res.msg)
      })
    }
  },
  mounted() {
    this.showgift()
  }
}
</script>

<style scoped>

</style>